<template>
  <div class="page-hero">
    <div class="topbar bg-black py-2 px-3 d-flex ai-center">
      <img src="../assets/logo.png" alt="..." height="30" />
      <div class="px-2 flex-1">
        <span class="text-white">王者荣耀</span>
        <span class="text-white ml-2">攻略站</span>
      </div>
      <router-link to="/" tag="div" class="text-white">更多英雄 &gt;</router-link>
    </div>
    <div class="top" v-if="model" :style="{'background-image': `url(${model.banner})`}">
      <div class="info text-white p-3 h-100 d-flex flex-column jc-end">
        <div class="fs-sm">{{model.title}}</div>
        <h2 class="my-2">{{model.name}}</h2>
        <div class="fs-sm">{{model.categories.map(v => v.name).join('/')}}</div>
        <div class="d-flex jc-between ai-center pt-2 fs-sm">
          <div>
            <span>难度</span>
            <span class="badge bg-primary">{{model.scores.difficult}}</span>
            <span>技能</span>
            <span class="badge bg-blue">{{model.scores.skill}}</span>
            <span>攻击</span>
            <span class="badge bg-danger">{{model.scores.attack}}</span>
            <span>生存</span>
            <span class="badge bg-dark">{{model.scores.survive}}</span>
          </div>
          <router-link to='/' tag="span" class="text-grey fs-sm">皮肤：2  &gt;</router-link>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    id: { required: true }
  },
  data() {
    return {
      model: null
    }
  },
  methods: {
    async fetch() {
      const res = await this.$http.get(`/heroes/${this.id}`)
      this.model = res.data
    }
  },
  created() {
    this.fetch()
  }
}
</script>

<style lang="scss">
@import '../assets/scss/varible';
.top {
  height: 50vw;
  background-size: auto 100%;



  .info {
    background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,1));
    .badge {
      margin: 0 .25rem;
      display: inline-block;
      width: 1rem;
      height: 1rem;
      border: 1px solid $border-color;
      border-radius: 50%;
      font-size: .75rem;
      line-height: .9rem;
      text-align: center;
  }
  }
}
</style>
